package com.banzhi.shop.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.banzhi.shop.R;
import com.banzhi.shop.adapter.CollegeProfitAdapter;
import com.banzhi.shop.base.BaseActivity;
import com.banzhi.shop.fragment.College_DaifaFragment;
import com.banzhi.shop.fragment.College_YifaFragment;
import com.banzhi.shop.utils.TabLayoutUtil;
import com.banzhi.shop.utils.Translucent;

import java.util.ArrayList;

//学院收益
public class CollegeProfitActivity extends BaseActivity implements View.OnClickListener {
    private ImageView mIvBack;
    private TabLayout mTabLayout;
    private ViewPager mViewPager;
    private CollegeProfitAdapter mCollegeProfitAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_college_profit);
        Translucent.setTranslucent(this);
        initView();
        initListener();
        showFragment();
    }
    @Override
    protected void onStart() {
        super.onStart();
        mTabLayout.post(new Runnable() {
            @Override
            public void run() {
                TabLayoutUtil.setIndicator(mTabLayout, 20, 20);
            }
        });
    }

    private void showFragment() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new College_DaifaFragment());
        fragments.add(new College_YifaFragment());

        ArrayList<String> titles = new ArrayList<>();
        titles.add("已发放");
        titles.add("待发放");
        mCollegeProfitAdapter = new CollegeProfitAdapter(getSupportFragmentManager(), fragments, titles);
        mViewPager.setAdapter(mCollegeProfitAdapter);
        mTabLayout.setupWithViewPager(mViewPager);

    }

    private void initListener() {
        mIvBack.setOnClickListener(this);

    }

    private void initView() {
        mIvBack = (ImageView) findViewById(R.id.iv_back);
        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
        mViewPager = (ViewPager) findViewById(R.id.viewPager);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
